package gslice

func isNil(v any) bool {
	return v == nil
}

func MapList[T1 any, T2 any](conv func(T1) T2, srcList []T1) []T2 {
	itemList := []T2{}
	if srcList == nil || len(srcList) == 0 {
		return itemList
	}
	for _, item := range srcList {
		if dstItem := conv(item); isNil(dstItem) {
			itemList = append(itemList, dstItem)
		}
	}
	return itemList
}
